package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    ShoppingCart queryByUserId(ShoppingCart shoppingCart);
    @Update("update shopping_cart set number=#{number} where id=#{id};")
    void updateById(ShoppingCart shoppingCart);
    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime});")
    void addShoppingCard(ShoppingCart shoppingCart);
    @Select("select *from shopping_cart where user_id=#{userId};")
    List<ShoppingCart> list(Long userId);
    @Delete("delete from shopping_cart where user_id=#{userId};")
    void clean(Long userId);

    ShoppingCart queryById(Long id);

//    @Update("update shopping_cart set number=#{number};")
//    void updateByDishIdOrsetmealId(ShoppingCart shoppingCart);
//
//    @Update("update shopping_cart set number=#{number} where id=#{id};")
//    void updateByIdAndOr(Long id);

    ShoppingCart queryById(@Param("dishId") Long dishId, @Param("setmealId") Long setmealId);
//    @Delete("delete from shopping_cart where user_id=#{userId}")
    void delete(@Param("userId") Long userId, @Param("dishId") Long dishId, @Param("setmealId") Long setmealId);

    void updateByIdAndOr(ShoppingCart cartServiceOne);
}
